layui.use(['jquery','layer','form','table','laydate','upload'],function() {
    var $ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, laydate = layui.laydate,
        upload = layui.upload;

    //列表分类 通过and驳回 22/1/15
    var result = 2;
    $('#adopt').click(function(){
        result = 2;
        getAdoptAndReject();
    });
    adopt = function adopt(){
        result = 2;
        getAdoptAndReject();
    }

    $('#reject').click(function(){
        result = 3;
        console.log(result);
        getAdoptAndReject();
    });
    reject = function reject() {
        result = 3;
        getAdoptAndReject();
    }


    //获取申请通过&&申请驳回 22/1/15 赵
    getAdoptAndReject();
    function getAdoptAndReject(){
        $.ajax({
            url: '/user/getAdoptAndReject'
            ,data: {'result': result}
            ,dataType: 'json'
            ,success:function(data){
                tableRender(data.data);
            }
        });
    }

    //渲染表格 赵 22/1/15
    tableRender = function tableRender(data){
        table.render({
            elem: '#layuiTbale'
            ,data: data
            ,limit: 10
            ,toolbar: '#toolutil'
            ,page: {
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']//自定义分页布局
                ,limits:[10,15,20]
                ,first: true
                ,last: true
            }
            ,cols: [[
                {checkbox: true}
                ,{type: 'numbers',title: '序号',align: 'center'}
                ,{field: 'fullName',title: '用户姓名',align: 'center'}
                ,{field: 'roleName',title: '申请职位',align: 'center'}
                ,{field: 'phone',title: '电话',align: 'center'}
                ,{field: 'applyDate',title: '申请时间',align: 'center'}
                ,{field: 'email',title: '邮箱',align: 'center'}
                ,{field: 'result',title: '申请状态',align: 'center',templet:function(data){
                        if(data.result == 1){
                            return '未通过';
                        }else if(data.result == 2){
                            return  '已通过';
                        }else if(data.result == 3){
                            return '未通过';
                        }else{

                        }
                    }}
                ,{title: '操作',align: 'center',templet:function(data){
                        return '<a style="color: #009688" onclick="see('+data.userId+')">查看</a> ';
                    }}
            ]]
        });
    }

    //普通检索 22/1/15 赵
    form.on('submit(sub)',function (data) {
        var user =data.field;
        $.ajax({
            url: '/user/getAdoptAndReject'
            ,data: {
                'fullName': user.fullName
                ,'account': user.account
                ,'applyDate': user.applyDate
                ,'result': result
            }
            ,dataType: 'json'
            ,success:function(data){
                tableRender(data.data);
            }
        });
    });

    //高级检索 22/1/15 赵
    advancedRetrieval = function advancedRetrieval(){
        layer.open({
            type: 2
            ,title: '高级检索'
            ,content: 'popup/apply-list-advancedRetrieval.html'
            ,area: ['650px','330px']
        });
    }
    //查看 赵 22/1/15
    see = function see(userId){
        $('#userId').val(userId);
        layer.open({
            type: 2
            ,title: '查看用户详情信息'
            ,content: 'popup/apply-list-see.html'
            ,area: ['960px','600px']
        });
    }

});
//返回首页
function backOff(){
    parent.jumpSystemHome();
}